<template>
  <BasicModal v-bind="$attrs" @register="registerModal" title="告警记录" width="1000px" @ok="handleSubmit">
    <BasicTable @register="registerTable" ref="selectTable" />
  </BasicModal>
</template>
<script lang="ts" setup>
import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicTable, useTable } from '@/components/Table';
import { getDeviceAlarmRecordPage } from '@/api/collection/device';
import { recordAlarmColumns } from './device.data';
import { reactive } from 'vue';

const searchInfo = reactive<Recordable>({ deviceId: 0 });
const [registerTable, { reload }] = useTable({
  canResize: true,
  api: getDeviceAlarmRecordPage,
  // immediate: false,
  columns: recordAlarmColumns,
  rowKey: 'id',
  searchInfo,
  // showTableSetting: false,
  // onColumnsChange: (data: ColumnChangeParam[]) => {
  //   console.log('ColumnsChanged', data);
  // },
  // showSelectionBar: true, // 显示多选状态栏
});

const [registerModal, {closeModal}] = useModalInner(async (data) => {
  searchInfo.deviceId = data.record.id;
  reload();
})

const handleSubmit = () => closeModal();

// onMounted(() => {
//   fetch();
// })

</script>
